package com.codrim.cs.data.server.dao.param;

import com.codrim.cs.data.rpc.dto.param.GeneralDataPermissionParam;

import org.apache.commons.collections.CollectionUtils;

import java.util.Set;

import lombok.Data;

/**
 * @author Liang.Zhuge
 * @date 07/03/2018
 */
@Data
public class AffDataRoleParam {
    /**
     * 权限:部门商务可见的部门id
     */
    private Set<Integer> advertiserManagerDepartmentIds;

    /**
     * 权限:个人商务可见的个人id
     */
    private Integer advertiserManagerId;

    public static AffDataRoleParam of(GeneralDataPermissionParam dto) {
        if (dto == null || (CollectionUtils.isEmpty(dto.getAdvertiserManagerDepartmentIdSet()) && dto.getAdvertiserManagerId() == null)) {
            return null;
        }

        AffDataRoleParam roleParam = new AffDataRoleParam();
        roleParam.setAdvertiserManagerId(dto.getAdvertiserManagerId());
        roleParam.setAdvertiserManagerDepartmentIds(dto.getAdvertiserManagerDepartmentIdSet());
        return roleParam;
    }
}
